import 'package:flutter_common_fragement/common/base/index.dart';

mixin NavigatorMixin {
  late BuildContext _buildContext;

  BuildContext get context => _buildContext;

  void setContext(BuildContext context) {
    _buildContext = context;
  }

  void push(BasePage page,
      {Function(dynamic)? callback, bool isAuth = true}) async {
    await NavigatorHelper.push(_buildContext, page: page, callback: callback);
  }

  void pop<T extends Object>([T? result]) {
    NavigatorHelper.pop(_buildContext, result);
  }

  Future<void> pushAndRemoveUntil(BasePage page) async {
    await NavigatorHelper.pushAndRemoveUntil(_buildContext, page: page);
  }

  void popUntil({String? routeName}) async {
    NavigatorHelper.popUntil(_buildContext, routeName: routeName);
  }
}
